package cn.cihon.ubi.qorosauto.biz;

import cn.cihon.ubi.qorosauto.bo.VehicleStandardData;
import cn.cihon.ubi.qorosauto.util.DateUtil;

/**
 * 
 * 此类实现行车数据的标准化
 * 
 * @author guodawei
 *
 */
public class VehicleStandardDataFactory {

	/**
	 * 此方法依据观致一期规则根据字符串数组将非标准行车信息转化为标准行车信息，并
	 * 返回标准信息对象
	 * 
	 * @param strs
	 * @return
	 */
	public static VehicleStandardData createVehicleStandardData(String[] strs){
		
		VehicleStandardData stdData = new VehicleStandardData();
		
		stdData.setHeaderFlag(Integer.valueOf(strs[0]));
		stdData.setVersion(Integer.valueOf(strs[1]));
		stdData.setRecordLen(Integer.valueOf(strs[2]));
		stdData.setVIN(strs[3]);
		stdData.setRecordTimestamp(DateUtil.StrToDate(strs[4]));
		stdData.setUserAccount(strs[5]);
		stdData.setCarDataTimestamp(strs[6]);
		stdData.setLongitude(Double.valueOf(strs[7]));
		stdData.setLatitude(Double.valueOf(strs[8]));
		stdData.setCanDataLen(Integer.valueOf(strs[9]));
		stdData.setDataPackageSize(Integer.valueOf(strs[10]));
		stdData.setKilometreMileage(Double.valueOf(strs[11]));
		stdData.setFLPressure(Double.valueOf(strs[12]));
		stdData.setFRPressure(Double.valueOf(strs[13]));
		stdData.setRLPressure(Double.valueOf(strs[14]));
		stdData.setRRPressure(Double.valueOf(strs[15]));
		stdData.setStatDoorAjarFL(Integer.valueOf(strs[16]));
		stdData.setStatDoorAjarFR(Integer.valueOf(strs[17]));
		stdData.setStatDoorAjarRL(Integer.valueOf(strs[18]));
		stdData.setStatDoorAjarRR(Integer.valueOf(strs[19]));
		stdData.setStatTrunkAjar(Integer.valueOf(strs[20]));
		stdData.setCarDataCount(Integer.valueOf(strs[21]));
		stdData.setCarDataSize(Integer.valueOf(strs[22]));
		stdData.setItemFlags(Integer.valueOf(strs[23]));
		stdData.setCarTime(strs[24]);
		stdData.setInstantConsum(Double.valueOf(strs[25]));
		stdData.setLongAcceleration(Double.valueOf(strs[26]));
		stdData.setSteeringPos(Double.valueOf(strs[27]));
		stdData.setSteeringAnglleSpeed(Double.valueOf(strs[28]));
		stdData.setSteeringPosState(Double.valueOf(strs[29]));
		stdData.setSTATSASCalibration(Double.valueOf(strs[30]));
		stdData.setVehicleSpeed(Double.valueOf(strs[31]));
		stdData.setEngineSpeed(Double.valueOf(strs[32]));
		
		return stdData;
	}
}
